import requests,json
#URL参数化
# paras={
#     'wd':'iphone',
#     'rsv_spt':'1'
# }

#消息头
# headers={
#     'user-agent':'my-app/0.0.1',
#     'auth-type':'jwt-token'
# }

#使用代理
proxies = {
    'http':'http://127.0.0.1:8888',
    'https':'http://127.0.0.1:8888',
}
# response=requests.get('http://www.baidu.com/s?',headers=headers,proxies=proxies,verify=False)
# print(response.text)


#消息体xml
# payload = '''
# <?xml version="1.0" encoding="UTF-8"?>
# <WorkReport>
#     <Overall>良好</Overall>
#     <Progress>30%</Progress>
#     <Problems>暂无</Problems>
# </WorkReport>
# '''
# r = requests.post("http://httpbin.org/post",
#                   data=payload.encode('utf8'),
#                   proxies=proxies)
# print(r.text)


#用urlencode
# payload = {'key1': 'value1', 'key2': 'value2'}
# r = requests.post("http://httpbin.org/post", data=payload,proxies=proxies)
# print(r.text)

#用json消息体
payload='''{
    "Overall":"良好",
    "Progress":"30%",
    "Problems":[
        {
            "No" : 1,
            "desc": "问题1...."
        },
        {
            "No" : 2,
            "desc": "问题2...."
        }
    ]
}'''
r = requests.post("http://httpbin.org/post",proxies=proxies,data=payload.encode('utf-8'))
# print(r.text)
print(r.status_code)
